package com.shrct.businessprocess.project;

import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.project.RCProjectMoney;
import edu.fudan.mylang.common.NumberExtensions;
import edu.fudan.mylang.pf.BaseDataType;
import org.eclipse.xtext.xbase.lib.DoubleExtensions;

public class RCProjectCBDSummaryInfo extends BaseDataType {
  public RCProjectCBDSummaryInfo() {
    super();
  }
  
  private Double contractAmount;
  
  public Double getContractAmount() {
    return this.contractAmount;
  }
  
  public RCProjectCBDSummaryInfo setContractAmount(final Double contractAmount) {
    this.contractAmount = contractAmount;
    return this;			
    
  }
  
  private Double netPriceAmount;
  
  public Double getNetPriceAmount() {
    return this.netPriceAmount;
  }
  
  public RCProjectCBDSummaryInfo setNetPriceAmount(final Double netPriceAmount) {
    this.netPriceAmount = netPriceAmount;
    return this;			
    
  }
  
  private Double grossProfit;
  
  public Double getGrossProfit() {
    return this.grossProfit;
  }
  
  public RCProjectCBDSummaryInfo setGrossProfit(final Double grossProfit) {
    this.grossProfit = grossProfit;
    return this;			
    
  }
  
  public Double getGrossProfitRate() {
    double _xifexpression = (double) 0;
    Double _nullsafe = NumberExtensions.nullsafe(this.contractAmount);
    boolean _notEquals = ((_nullsafe).doubleValue() != 0);
    if (_notEquals) {
      Double _nullsafe_1 = NumberExtensions.nullsafe(this.grossProfit);
      Double _nullsafe_2 = NumberExtensions.nullsafe(this.contractAmount);
      double _divide = DoubleExtensions.operator_divide(_nullsafe_1, _nullsafe_2);
      _xifexpression = _divide;
    } else {
      _xifexpression = 0d;
    }
    return Double.valueOf(_xifexpression);
  }
  
  public void performUpdate(final RCProject project) {
    RCProjectMoney _totalContractAmount = project.getTotalContractAmount();
    Double _hostAmount = _totalContractAmount.toHostAmount();
    Double _nullsafe = NumberExtensions.nullsafe(_hostAmount);
    this.contractAmount = _nullsafe;
    RCProjectMoney _totalBudgetNetAmount = project.getTotalBudgetNetAmount();
    Double _hostAmount_1 = _totalBudgetNetAmount.toHostAmount();
    Double _nullsafe_1 = NumberExtensions.nullsafe(_hostAmount_1);
    this.netPriceAmount = _nullsafe_1;
    double _minus = DoubleExtensions.operator_minus(this.contractAmount, this.netPriceAmount);
    Double _nullsafe_2 = NumberExtensions.nullsafe(Double.valueOf(_minus));
    this.grossProfit = _nullsafe_2;
  }
  
  public static RCProjectCBDSummaryInfo create() {
    return new RCProjectCBDSummaryInfo();
    
    
  }
}
